<?php
/**
 * Created by PhpStorm.
 * User: wangjie
 * Date: 2018/11/7
 * Time: 14:44
 */
namespace common\services;

use common\services\tool\ToolIdentity;

class ToolIdentityService
{
    /**
     * 身份证多数据信息
     * @param $idCard
     * @return mixed
     */
    public static function idCardAnalysis($idCard)
    {
        // 先判断是否是真实身份证
        $isIdCard = ToolIdentity::isIDCard($idCard);
        $result['validation'] = $isIdCard;
        $result['data'] = [];
        if ($isIdCard == true) {
            // 获取生日时间戳与是否成年判断
            $getBirthday = ToolIdentity::getBirthday($idCard);
            $result['data']['is_adult']      = $getBirthday['is_adult'];
            $result['data']['birthday_date'] = $getBirthday['b_day'];
            $result['data']['birthday_time'] = $getBirthday['b_time'];
            $result['data']['age']           = $getBirthday['age'];
            $result['data']['day_passed']    = $getBirthday['day_passed'];
            // 获取性别
            $result['data']['sex']           = ToolIdentity::getSexSign($idCard);
            // 获取省份
            $result['data']['area']          = ToolIdentity::provinceNum(substr($idCard, 0, 2));
            // 获取星座
            $result['data']['constellation'] = ToolIdentity::getStarSign($idCard);
            // 获取生肖
            $result['data']['zodiac']        = ToolIdentity::getAnimalSign($idCard);
        }
        return $result;
    }


}
